import subprocess



res = subprocess.Popen('dir', shell=True, stdout=subprocess.PIPE)
str1=res.stdout.read().decode('gbk')

#read()读取全部 readline()读取一行